function checkName() {
    var userName = document.getElementById("userName");
    if (userName.value == "") {
        userName.classList.add("wrong");
        alert("用户昵称不能为空!");
        return false;
    } else {
        userName.classList.remove("wrong");
        return true;
    }
}

function checkPhone() {
    var userPhone = document.getElementById("userPhone");
    var regex = /^1[3-9]\d{9}$/;
    if (userPhone.value == "") {
        userPhone.classList.add("wrong");
        alert("手机号不能为空!");
        return false;
    } else {
        if (!regex.test(userPhone.value)) {
            userPhone.classList.add("wrong");
            alert("手机号格式不正确!");
            return false;
        }else{
            userPhone.classList.remove("wrong");
            return true;
        }
    }
}

function resetForm(){
    var userName = document.getElementById("userName");
    var userPhone = document.getElementById("userPhone");
    
    userName.classList.remove("wrong");
    userPhone.classList.remove("wrong");
}

function checkForm() {
    if (checkName() && checkPhone()) {
        return true;
    } else {
        return false;
    }
}